/**
 * Created with JetBrains PhpStorm.
 * User: jiangshuguang
 * Date: 14-8-7
 * Time: 下午3:00
 * To change this template use File | Settings | File Templates.
 */
var createUi = require("iphone:widget/ui/base/base.js").createUi;
var Dialog = createUi({
    _data:{
        title:"提示",
        content:"",
        width:400,
        onConfirm:function(){},
        onCancel:function(){}
    },

    _create:function(){
        var me = this,
            title = this.data("title"),
            content = this.data("content"),
            $root =
                $('' +
                    '<div title="'+title+'">' +
                    '<div class="content" style="font-size:15px;text-align: left;font-family: Hiragino Sans GB, Microsoft YaHei;margin:10px 0;text-align: center;color:#636363;line-height: 30px;">' + content + '</div>' +
                    '</div>' ).dialog({
                        modal: true,
                        autoOpen:false,
                        width:me.data('width'),
                        buttons: {
                            "关闭":function(){
                                me.trigger("cancel");
                                $(this).dialog('close');
                            }
                        }
                    });
        this.data({
            $root:$root
        });


        $root.parent('.ui-dialog').find(".ui-button").css({
            'border':'0',
            'background':"#00a990",
            'color':'#fff'
        });
    },
    _init:function(){

    },

    show:function(content){
        var $root = this.data("$root");
        !!content && $root.find(".content").html(content);
        $root.dialog('open');
    },

    hide:function(){
        this.data("$root").dialog('close');
    }
});

$.extend(exports,{
    Dialog:Dialog,
    dialog:function(informTxt,title){
        return new Dialog(informTxt,title);
    }
});